package cn.edu.cuit.filter;

import java.io.*;
import javax.servlet.*;

public class MyFilter03 implements Filter {
	private String characterEncoding;
	FilterConfig fc;

	public void init(FilterConfig fConfig) throws ServletException {
		// 获取FilterConfig对象
		this.fc = fConfig;
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		// 将输出置为html
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		// 通过运行，观察过滤器的运行情况
		out.write("Hello MyFilter03");
		// 输出参数信息
		characterEncoding = fc.getInitParameter("encoding");
		// 控制台输出标记
		System.out.println("encoding初始化参数的值为：" + characterEncoding+"<br>");
		// 放行
		chain.doFilter(request, response);
	}

	public void destroy() {
	}
}
